<template>
	<view class="my">
		<view class="header" @click="userId?'':$handleOpenUrl('/pages/login/index')">
			<view class="list_info">
				<image :src="userInfo.user.headImage || 'https://oss-shop.cciinet.com/files/MiniProgram/circle_avatar.png'"></image>
				<view class="name">
					<view class="name1">{{userId?userInfo.user.name:"登录"}}</view>
					<!-- <view class="name2">{{userInfo.shopCompany.comName}}</view> -->
				</view>
			</view>
			<!-- #ifdef !APP-PLUS -->
			<image class="img" src="https://oss-shop.cciinet.com/files/MiniProgram/gengduo@2x.png" mode="widthFix"></image>
			<!-- #endif -->
		</view>
		<view class="menu">
			<view class="item_info" @click="$handleOpenUrl('/pages/profile/feedback')">
				<view class="info">
					<image src="https://oss-shop.cciinet.com/files/MiniProgram/feedback.png"></image>
					<view class="item">用户反馈</view>
				</view>
				<image class="img" src="https://oss-shop.cciinet.com/files/MiniProgram/gengduo@2x.png" mode="widthFix"></image>
			</view>
			<view class="item_info" @click="handleIdent">
				<view class="info">
					<image src="https://oss-shop.cciinet.com/files/MiniProgram/ident.png"></image>
					<view class="item">我的认证</view>
				</view>
				<image class="img" src="https://oss-shop.cciinet.com/files/MiniProgram/gengduo@2x.png" mode="widthFix"></image>
			</view>
			<view class="item_info"  @click="$handleOpenUrl('/pages/profile/release')">
				<view class="info">
					<image src="https://oss-shop.cciinet.com/files/MiniProgram/myfa.png"></image>
					<view class="item">我的供应</view>
				</view>
				<image class="img" src="https://oss-shop.cciinet.com/files/MiniProgram/gengduo@2x.png" mode="widthFix"></image>
			</view>
			<view class="item_info" @click="$handleOpenUrl('/pages/profile/block')">
				<view class="info">
					<image src="https://oss-shop.cciinet.com/files/MiniProgram/block.png"></image>
					<view class="item">黑名单</view>
				</view>
				<image class="img" src="https://oss-shop.cciinet.com/files/MiniProgram/gengduo@2x.png" mode="widthFix"></image>
			</view>
			<!--#ifdef MP-WEIXIN-->
			<button open-type="contact">
				<view class="item_info">
					<view class="info">
						<image src="https://oss-shop.cciinet.com/files/MiniProgram/wode.png"></image>
						<view class="item">在线客服</view>
					</view>
					<image class="img" src="https://oss-shop.cciinet.com/files/MiniProgram/gengduo@2x.png" mode="widthFix"></image>
				</view>
			</button>
			<!-- #endif-->
			<!-- #ifdef H5 -->
			<view class="item_info" @click="handleChat">
				<view class="info">
					<image src="https://oss-shop.cciinet.com/files/MiniProgram/wode.png"></image>
					<view class="item">在线客服</view>
				</view>
				<image class="img" src="https://oss-shop.cciinet.com/files/MiniProgram/gengduo@2x.png" mode="widthFix"></image>
			</view>
			<!-- #endif -->
			<view class="item_info" @click="handlePhone">
				<view class="info">
					<image src="https://oss-shop.cciinet.com/files/MiniProgram/phone.svg"></image>
					<view class="item">客服电话</view>
				</view>
				<view class="phone">4000-666-591</view>
			</view>
			
		</view>
		<view class="loginOut" @click="handleLoginOut" v-if="userId">
			退出登录
		</view>
	</view>
</template>

<script>
	import { $handleStatistcs } from "@/utils/statistics.js"
	export default {
		data() {
			return {
				userInfo: {
					shopCompany: {},
					user: {}
				},
				userId:"",
			}
		},
		onShow() {
			this.handleInfo()
			$handleStatistcs()
			// this.onGotUserInfo()
		},
		methods: {
			handleInfo() {
				if (uni.getStorageSync("userInfo")) {
					this.userInfo = JSON.parse(uni.getStorageSync("userInfo"))
					this.userId = uni.getStorageSync("userId")
				}else{
					this.userInfo= {
						shopCompany: {},
						user: {}
					}
					this.userId=""
				}
			},
			handleIdent() {
				if(this.userInfo.shopCompany.examineType==0) {
					uni.showToast({
						title:"您的认证正在审核中！",
						icon:"none"
					})
					return
				}
				if(this.userInfo.shopCompany.examineType==1) {
					uni.showToast({
						title:"您的认证已经审核通过！",
						icon:"none"
					})
					return
				}
				 this.$handleOpenUrl('/pages/login/personalData')
			},
			// onGotUserInfo() {
			// 	uni.login({
			// 		provider: 'weixin',
			// 		success: function(loginRes) {
			// 			// 获取用户信息				
			// 			uni.getUserInfo({
			// 				provider: 'weixin',
			// 				success: function(res) {
			// 					console.log(res)
			// 				},
			// 				fail() {
			// 					uni.showToast({
			// 						title: '请点击授权进行登录',
			// 						icon: 'none'
			// 					});
			// 				}
			// 			});
			// 		}
			// 	});
			// },
			handlePhone() {
				uni.makePhoneCall({
					phoneNumber: '4000-666-591'
				})
			},
			handleChat() {
				window._MICHAT.floatClick();
				return false;
			},
			handleLoginOut() {
				uni.removeStorageSync('userId')
				uni.removeStorageSync('userInfo')
				this.handleInfo()
				this.$handleOpenUrl("/pages/home/index",0)
			}
		}
	}
</script>

<style lang="scss" scoped>
	.my {
		.header {
			margin: 0 30upx;
			margin-top: 20upx;
			display: flex;
			justify-content: space-between;
			align-items: center;
			border-bottom: 1upx solid #eee;
			padding-bottom: 20upx;
			height: 140upx;

			.list_info {
				display: flex;
				align-items: center;

				image {
					width: 120upx;
					height: 120upx;
				}

				.name {
					font-size: 26upx;
					margin-left: 10upx;
					display: flex;
					flex-direction: column;
					align-items: flex-start;
					.name1 {
						font-size: 30upx;
						font-weight: bold;
						margin-bottom: 10upx;
					}

				}
			}

			.img {
				width: 10upx;
			}
		}

		.item_info {
			display: flex;
			justify-content: space-between;
			margin: 0 30upx;
			height: 90upx;
			align-items: center;
			border-bottom: 1upx solid #eee;

			.info {
				display: flex;
				align-items: center;
				font-size: 28upx;

				image {
					width: 20px;
					height: 20px;
					margin-right: 10upx;
				}
			}

			.img {
				width: 10upx;
			}
		}
		.loginOut{
			position: fixed;
			bottom:100px;
			width: 100%;
			text-align: center;
		}
	}
</style>
